package com.carl.leetcode.math;

/**
 * Created by carlXie on 2016/1/5.
 * email: kkrimen@gmail.com
 */
public class PalinDromeNumber {
    public static void main(String[] args) {
        System.out.println(isPalindorme(12321));
    }

    public static boolean isPalindorme(int x) {
        int d = 1;
        if(x < 0) return false;

        while (x / d >= 10) {
            d *= 10;
        }
        while(x > 0) {
            if(x / d != x % 10)
                return false;
            x %= d;
            x /= 10;
            d /= 100;
        }

        return true;

    }
}
